#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int result = INT_MAX;
        int sum = 0;
        int head = 0;
        int length = 0;
        for (int tail = 0; tail < nums.size(); tail++)
        {
            sum += nums[tail];
            while (sum >= target)
            {
                length = tail - head + 1;
                result = result < length ? result : length;
                sum -= nums[head++];
            }
        }
        return result;

    }
};

int main()
{
    vector<int> arr = { 2,3,1,2,4,3 };
    Solution s;
    s.minSubArrayLen(7, arr);
    return 0;
}